//
//  MINUtils.h
//  loginDemo
//
//  Created by lym on 2017/8/19.
//  Copyright © 2017年 lym. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, MINFontType) {
    MINFontTypeRegular,
    MINFontTypeBold,
    MINFontTypeMedium
};

@interface MINUtils : NSObject

+ (UIButton *)createBtnWithTitle:(NSString *)title titleColor:(UIColor *)titleColor backgroundColor:(UIColor *)color cornerRadius:(CGFloat)radius font:(UIFont *)font;

+ (UITextField *)createTextFieldWithPlacehold:(NSString *)holdText font:(UIFont *)font textColor:(UIColor *)color;

+ (UILabel *)createLabelWithText:(NSString *)text font:(UIFont *)font textColor:(UIColor *)textColor;

+ (UIView *)createViewWithRadius:(CGFloat)radius;

+ (UITextView *)createTextViewWithPlaceholder:(NSString *)text font:(UIFont *)font backgroundColor:(UIColor *)color cornerRadius:(CGFloat)radius textColor:(UIColor *)textColor;

+ (NSMutableAttributedString *)getTextAttributeStringWithPlaceHold:(NSString *)holdText;

//时间戳转日期
+ (NSString *)getSystemTimeTimestamp:(NSString *)timestamp;
+ (NSString *)getSystemTimeTimestamp:(NSString *)timestamp formatter:(NSString *)formatterString;

+ (NSString *)getCustomTime:(NSString *)gmtStr Timestamp:(NSString *)timestamp;
+ (NSString *)getCustomTime:(NSString *)gmtStr Timestamp:(NSString *)timestamp formatter:(NSString *)formatterString;

//+ (NSString *)getTimeFromTimestamp:(NSString *)timestamp formatter:(NSString *)formatterString;
//+ (NSString *)getTimeFromTimestamp:(NSString *)timestamp formatter:(NSString *)formatterString usedTime:(int)usedTime;

// 和当前时间对比
+ (NSString *)getDuringTimeFromTimestamp:(NSString *)timestamp;

+ (NSURL *)getHeadUrl:(NSString *)head;

//比较两个日期大小
- (NSInteger)compare:(NSDate *)startTime to:(NSDate *)endTime;
// 计算时长 单位分钟
+ (NSString *)getUsingTimeByUsed:(NSString *)usedTime;
// 计算时长  秒
+ (NSString *)getUsingTimeByCurrTime:(NSString *)usedTime;

//获取字符串的长度
//获取字符串宽
+(CGSize)measureSinglelineStringSize:(NSString*)str andFont:(UIFont*)wordFont;

//获取字符串宽 // 传一个字符串和字体大小来返回一个字符串所占的宽度
+(float)measureSinglelineStringWidth:(NSString*)str andFont:(UIFont*)wordFont;

//获取字符串高 // 传一个字符串和字体大小来返回一个字符串所占的高度
+(float)measureMutilineStringHeight:(NSString*)str andFont:(UIFont*)wordFont andWidthSetup:(float)width;

//正则判断
+ (BOOL)checkEmail:(NSString *)email;
+ (BOOL)checkInvCode:(NSString *)code;

//处理中文
+ (NSString *)strUTF8Encoding:(NSString *)str;

//获取系统时区
+ (NSString *)getCusZoneString;

// 获取手机型号
+ (NSString *)getIphoneType;

// 获取 Bundle num
+ (NSString *)getBundleNum;

#pragma mark - FindCurrentShowingViewController
///获取Window当前显示的视图控制器ViewController
+ (UIViewController *)findCurrentShowingViewController;

/**
 *  获取Window当前显示的视图控制器ViewController
 *
 *  @param vc   从哪个界面开始分析
 *
 *  @return 当前显示的视图控制器ViewController
 */
+ (UIViewController *)findCurrentShowingViewControllerFrom:(UIViewController *)vc;

#pragma mark - FindBelongViewControllerForView
+ (nullable UIViewController *)findBelongViewControllerForView:(UIView *_Nonnull)view;

/**
 *  截取URL中的参数
 *
 *  @return NSMutableDictionary parameters
 */
+ (NSMutableDictionary *_Nonnull)getURLParameters:(NSString *_Nonnull)url;

/**
*  * 请描述您的问题
*
*  @return NSMutableAttributedString title
*/
+(NSMutableAttributedString *_Nullable) getTitleAttributedString:(NSString *_Nonnull)title;

+(NSMutableAttributedString *_Nullable) getTitleAttributedStringTwo:(NSString *_Nonnull)title;

//判断NSString值是否为空或null并转换为空字符串
+ (NSString *_Nonnull)nullToString:(id _Nonnull )string;

//H5国际化
+ (NSString *_Nonnull)languagetypeAgreement:(id _Nonnull )agreementUrl;

@end
